
//查看证件

function viewCerificate(){
	var rows = $( "#manage-cerificate" ).jqGrid( 'getGridParam', 'selarrrow' );
	var rowsData;
	// 判断是否选中行
	if ( rows.length > 0 ) {
		rowsData = $( "#manage-cerificate" ).jqGrid( "getRowData", rows[0] );
		var id=rowsData.id;
	$( "body" ).prepend( '<div class="quanping" ></div>' );
	$( ".quanping" ).after( '<div id="cerificate-view"></div>' );
	$( "#cerificate-view" ).load( "../manage/view/viewLicense.html?id="+id, null, 
		function( response, status, xml ) {
			if ( status === "success" ) {
				$( ".quanping" ).height( $(document).height() );
				$( "#cerificate-view > .preview-frame" ).fadeIn( "normal" );
				getData( userId );
			} else {
				alert( "查看失败！" );
				$("#cerificate-view, .quanping").remove();
			}
		}
	);
	}else{
		alert("请选择一行!");
	}
}


//审核不通过
//flag=1 关闭查看详情窗口
//flag=0 
function failCerificate(flag){

	/**
	 * rows 获取所选择行的ID，支持单选、多选
	 *
	 * @type {Object}
	 */

	var rows = $( "#manage-cerificate" ).jqGrid( 'getGridParam', 'selarrrow' );

	/**
	 * rowsData
	 *
	 * @type {Object}
	 */

	var rowsData;

	
	// 判断是否选中行
	if ( rows.length > 0 ) {
		rowsData = $( "#manage-cerificate" ).jqGrid( "getRowData", rows[0] );		
		if(rowsData.licenseStateString==="未提交审核资料"){
			alert("该用户未提交审核资料！不能审核！");
			return;
		}
		if ( confirm( "您确认不通过该证件吗?" ) ) {

			// 循环遍历所选择行，获取行GlobalID
			
			
			$.ajax({
				type: "POST",
				contentType: "application/x-www-form-urlencoded;charset=UTF-8",
				url: "../admin/deny.html",
				data: "userId=" + rowsData.id ,
				success: function() {
					alert( "操作成功!" );
					$( "#manage-cerificate" ).trigger( "reloadGrid" );
					if(flag==1){
						$(".preview-close").trigger("click");
					}
				},
				error: function(textStatus) {
					alert( textStatus );
				}
			});
		}
	} else {
		alert( "请先选择一行！" );
	}
}

//通过证件
//flag=1 关闭查看详情窗口
//flag=0 
function passCerificate(flag){

	/**
	 * rows 获取所选择行的ID，支持单选、多选
	 *
	 * @type {Object}
	 */

	var rows = $( "#manage-cerificate" ).jqGrid( 'getGridParam', 'selarrrow' );

	/**
	 * rowsData
	 *
	 * @type {Object}
	 */

	var rowsData;

	
	// 判断是否选中行
	if ( rows.length > 0 ) {
		rowsData = $( "#manage-cerificate" ).jqGrid( "getRowData", rows[0] );		
		if(rowsData.licenseStateString==="未提交审核资料"){
			alert("该用户未提交审核资料！不能审核！");
			return;
		}
		if ( confirm( "您确认要通过证件吗?" ) ) {

			// 循环遍历所选择行，获取行GlobalID
			
				//rowsData = $( "#manage-cerificate" ).jqGrid( "getRowData", rows[0] );		
			
			$.ajax({
				type: "POST",
				contentType: "application/x-www-form-urlencoded;charset=UTF-8",
				url: "../admin/passChecking.html",
				data: "userId=" + rowsData.id ,
				success: function() {
					alert( "操作成功" );
					$( "#manage-cerificate" ).trigger( "reloadGrid" );
					if(flag==1){
						$(".preview-close").trigger("click");
					}
					
				},
				error: function(textStatus) {
					alert( textStatus );
				}
			});
		}
	} else {
		alert( "请先选择一行！" );
	}
}

/**
 * getData 根据userId获取详细数据
 * 
 */

function getData(userId) {
	$.ajax({
		type: "POST",
		contentType: "application/x-www-form-urlencoded;charset=UTF-8",
		url: "..",
		data: "userIds=" + userId,
		success: function(result) {
			
		},
		error: function(textStatus) {
			alert( "加载用户数据失败！" );
		}
	});
}
function blockedUser() {

	/**
	 * rows 获取所选择行的ID，支持单选、多选
	 *
	 * @type {Object}
	 */

	var rows = $( "#manage-cerificate" ).jqGrid( 'getGridParam', 'selarrrow' );

	/**
	 * rowsData
	 *
	 * @type {Object}
	 */

	var rowsData;

	
	// 判断是否选中行
	if ( rows.length > 0 ) {
		rowsData = $( "#manage-cerificate" ).jqGrid( "getRowData", rows[0] );
		if(rowsData.stringactivity==="已冻结"){
			alert("此账户已冻结!");
		}else{
		if ( confirm( "您确认要冻结所选的用户吗?" ) ) {
			$.ajax({
				type: "POST",
				contentType: "application/x-www-form-urlencoded;charset=UTF-8",
				url: "../admin/freeze.html",
				data: "userId=" + rowsData.id,
				success: function() {
					alert( "操作成功！" );
					$( "#manage-cerificate" ).trigger( "reloadGrid" );
					
				},
				error: function(textStatus) {
					alert( textStatus );
				}
			});
		}
	} 
	}else {
		alert( "请先选择一行！" );
	}
}

function unblocked() {

	/**
	 * rows 获取所选择行的ID，支持单选、多选
	 *
	 * @type {Object}
	 */

	var rows = $( "#manage-cerificate" ).jqGrid( 'getGridParam', 'selarrrow' );

	/**
	 * rowsData
	 *
	 * @type {Object}
	 */

	var rowsData;

	
	// 判断是否选中行
	if ( rows.length > 0 ) {
		rowsData = $( "#manage-cerificate" ).jqGrid( "getRowData", rows[0] );
		if(rowsData.stringactivity==="正常"){
			alert("此账户是正常的!");
		}else{
		if ( confirm( "您确认要解冻所选的用户吗?" ) ) {
			$.ajax({
				type: "POST",
				contentType: "application/x-www-form-urlencoded;charset=UTF-8",
				url: "../admin/release.html",
				data: "userId=" + rowsData.id,
				success: function() {
					alert( "操作成功！" );
					$( "#manage-cerificate" ).trigger( "reloadGrid" );
					
				},
				error: function(textStatus) {
					alert( textStatus );
				}
			});
		}
	} 
	}else {
		alert( "请先选择一行！" );
	}
}

